package cn.itcast.mapper;


import cn.itcast.pojo.Emp;
import cn.itcast.pojo.EmpGender;
import cn.itcast.pojo.QuaryParma;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;
import java.util.Objects;

@Mapper
public interface EmpMapper {
    //查询全部
    List<Emp> findAll();

    //分页查询
    List<Emp> findByCondition(QuaryParma quaryParma);

    //添加员工
    @Insert("insert into emp (id,username,password,name,gender,phone,job,salary,image,entry_date,dept_id,create_time,update_time) values (null,#{username},#{password},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int add(Emp emp);


    //批量删除员工
    int delete(@Param("ids") int[] ids);

    //根据id查找员工
    Emp findById(Integer id);


    //更新员工信息
    int update(Emp emp);
    @Select("select image from emp where id = #{id}")
    String findImageById(Integer id);
    //根据id批量查找员工
    List<Emp> findByIds(@Param("ids") int[] ids);
    //登录
    @Select("select * from emp where username = #{username} and password = #{password}")
    Emp login(Emp emp);


    @Select("select * from emp where username = #{username}")
    Emp findByUsername(String username);

}
